package de.wbh.gwt.form.layouter.shared.area;

import javax.inject.Inject;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

import de.wbh.gwt.form.layouter.shared.Step;
import de.wbh.gwt.form.layouter.shared.activity.ActivityFactory;
import de.wbh.gwt.form.layouter.shared.place.CreateConfigurationPlace;
import de.wbh.gwt.form.layouter.shared.place.EditPlace;
import de.wbh.gwt.form.layouter.shared.place.LoadPlace;

public class Deck2RightAreaActivityMapper implements ActivityMapper {

	private final ActivityFactory activityFactory;

	@Inject
	public Deck2RightAreaActivityMapper(ActivityFactory activityFactory) {
		this.activityFactory = activityFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof CreateConfigurationPlace) {
			Step step = ((CreateConfigurationPlace) place).getStep();
			switch (step) {
			case UPLOAD_PDF:
				return this.activityFactory.getLoadPdfActivity();
			case UPLOAD_FIELDS:
				return this.activityFactory.getLoadFieldsActivity();
			case SAVE:
				return this.activityFactory.getSaveConfigurationActivity();
			default:
				break;
			}
		} else if (place instanceof EditPlace)
			return this.activityFactory.getEditPositionsActivity(((EditPlace) place).getPdfName(), ((EditPlace) place).getConfigurationName());
		else if (place instanceof LoadPlace)
			return this.activityFactory.getLoadConfigurationActivity();
		return null;
	}
}
